import axios from 'axios';
import qs from 'qs';

axios.defaults.timeout = 15000;
axios.defaults.withCredentials = true;

axios.interceptors.request.use(config => {
  return config;
}, err => {
  return Promise.resolve(err);
});

axios.interceptors.response.use(response => {
  return response.data;
}, (err) => {
  return Promise.resolve(err);
});

const getRequest = (url, params) => {
  return axios({
    method: 'get',
    url: url,
    params: params,
    paramsSerializer: params => {
      return qs.stringify(params, {
        indices: false
      })
    }
  });
};

export const getStatsData = (params) => {
  return getRequest('https://aqsc.eut.org.cn/user/static/homeData.json', params)
}